package com.imooc.aspectJ.demo2;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * @author wangc
 */
public class MyAspectXml {

    /**
     * 前置通知
     *
     * @param joinPoint
     */
    public void before(JoinPoint joinPoint) {
        System.out.println("XML方式的前置通知=======================" + joinPoint);
    }

    /**
     * 后置通知
     *
     * @param result
     */
    public void aftetReturing(Object result) {
        System.out.println("XML方式的后置通知===================== " + result);
    }

    /**
     * 环绕通知
     *
     * @param proceedingJoinPoint
     * @return
     * @throws Throwable
     */
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("XML方式的环绕前通知===================== " + proceedingJoinPoint);
        Object obj = proceedingJoinPoint.proceed();
        System.out.println("XML方式的环绕后通知===================== " + proceedingJoinPoint);
        return obj;
    }

    /**
     * 异常抛出通知
     */
    public void afterThrowing(Throwable e) {
        System.out.println("XML方式的异常抛出通知===================== "+e.getMessage());
    }

    public void after() {
        System.out.println("XML方式的最终通知===================== ");
    }
}
